/**
 *
 * @author 
 *
 */
class GameView extends egret.DisplayObjectContainer {
    private _mapCon: egret.DisplayObjectContainer;
    private _buildCon: egret.DisplayObjectContainer;
    private _armyCon: egret.DisplayObjectContainer;
    private _skillCon: egret.DisplayObjectContainer;
	
    constructor() {
        super();
        this.initView();
        this.addEvent();
    }
    private addEvent(): void {
        this.addEventListener(egret.Event.ENTER_FRAME,this.enterFrame,this);
        this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.TOUCH_TAP_Handle,this);
    }
    private removeEvent(): void {
        this.removeEventListener(egret.Event.ENTER_FRAME,this.enterFrame,this);
        this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.TOUCH_TAP_Handle,this);

    }
    private enterFrame(e: egret.Event): void {
		if(GameManager.i.gameflag){
			EnemyManage.i.enterFrame();
			BuildManage.i.enterFrame();
			BowManage.i.enterFrame();
			SkillManager.i.enterFrame();
		}
    }
    
    private initView(): void {
        this._mapCon = new egret.DisplayObjectContainer();
        this.addChild(this._mapCon);
        MapManager.i.setup(this._mapCon);
		
        this._armyCon = new egret.DisplayObjectContainer();
        this.addChild(this._armyCon);
        EnemyManage.i.setup(this._armyCon);
		
        BowManage.i.setup(this._armyCon);
        		
        this._buildCon = new egret.DisplayObjectContainer();
        this.addChild(this._buildCon);
        BuildManage.i.setup(this._buildCon);
        		
        this._skillCon = new egret.DisplayObjectContainer();
        this.addChild(this._skillCon);
        SkillManager.i.setup(this._skillCon);
        
    }
    private TOUCH_TAP_Handle(e: egret.TouchEvent): void {
        if(e.target instanceof ArmyBase){
			SkillManager.i.hitOne(e.target);
		}
    }
	
	
    public dispose(): void {
        this.removeEvent();
        		
        this._mapCon.removeChildren();
        this._buildCon.removeChildren();
        this._armyCon.removeChildren();
    }
    
    
    
    
}